package exception;

public class Student {
    private int age;

    public Student() {
    }


    /**
     * 获取
     *
     * @return age
     */
    public int getAge() {
        return age;
    }

    /**
     * 设置
     *
     * @param age
     */
    public void setAge(int age) {
        if (age > 100 || age < 0) {
            throw new AgeOutOfBoundsException(age+"范围有误,应在0-100岁");
        } else {
            this.age = age;
        }
    }

    @Override
    public String toString() {
        return "Student{age = " + age + "}";
    }
}
